package com.genwangsun.nettydemo.config.redisInfra;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RedisConfig {

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer()
                // use "rediss://" for SSL connection
                .setAddress("redis://127.0.0.1:6379")
                .setDatabase(0)
                .setTimeout(3000);
        config.setCodec(JsonJacksonCodec.INSTANCE);
        // 2. Create Redisson instance
        // Sync and Async API
        return Redisson.create(config);
    }
}
